
import openpyxl
import os
class write_data():
    def open_xlsx(self,file_path,row_num,col_num,cells_value):
        ox=openpyxl.load_workbook(os.path.dirname(__file__)+file_path)
        # 打开一个文件对象
        # 如果文件已经打开,运行到此处会报错
        write_cell=ox.active.cell(row_num,col_num,cells_value)
        # 传入单元格中要写入的行/列,值的信息
        ox.save(os.path.dirname(__file__)+file_path)
        #关闭并保存文件对象
        return write_cell
    

write_xlsx_data=write_data()